package com.lg.partition14;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/4/14 10:21
 */
public class P1395会议 {

    private static final int N = 50010, M = 2 * N, INF = 0x3f3f3f3f;
    private static int[] h = new int[N], e = new int[M], ne = new int[M], size = new int[N];
    private static int[] f = new int[N];
    private static int n, idx = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = Integer.parseInt(reader.readLine());
        Arrays.fill(h, -1);
        for (int i = 0; i < n - 1; i++) {
            String[] ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]);
            add(a, b);
            add(b, a);
        }
        f[1] = dfsdown(1, -1, 0);
        dfsup(1, -1);
        int ans1 = 1, ans2 = INF;
        for (int i = 1; i <= n; i++) {
            if (ans2 > f[i]) {
                ans2 = f[i];
                ans1 = i;
            }
        }
        writer.write(String.format("%d %d\n", ans1, ans2));
        writer.flush();
    }

    private static void dfsup(int u, int fa) {
        for (int i = h[u]; i != -1; i = ne[i]) {
            int v = e[i];
            if (v == fa) continue;
            f[v] = f[u] + n - 2 * size[v];
            dfsup(v, u);
        }
    }

    private static int dfsdown(int u, int fa, int depth) {
        size[u] = 1;
        int res = depth;
        for (int i = h[u]; i != -1; i = ne[i]) {
            int v = e[i];
            if (v == fa) continue;
            res += dfsdown(v, u, depth + 1);
            size[u] += size[v];
        }
        return res;
    }

    private static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }
}
